﻿using guosange.BLL;
using guosange.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Security;

namespace guosange.Controll
{
    public class UserController : Controller
    {
        
        public ActionResult Login()
        {
            return View(new T_User());
        }

        public ActionResult Validate(string username, string userpwd)
        {
            UserBLL bll = new UserBLL();
            var ret = bll.Login(username, userpwd);
            FormsAuthentication.SignOut();
            if (ret.Success)
            {
                FormsAuthentication.RedirectFromLoginPage(username, false);
                return RedirectToAction("index", "home");
            }
            else
            {
                return Json(ret);
            }              
          
        }
    }
}
